<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** @preserve jsPDF ( ${buildDate} ${commitID} )
<span class='line'>  2</span> Copyright (c) 2010 James Hall, https://github.com/MrRio/jsPDF
<span class='line'>  3</span> Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
<span class='line'>  4</span> MIT license.
<span class='line'>  5</span> */</span><span class="WHIT">
<span class='line'>  6</span> 
<span class='line'>  7</span> </span><span class="COMM">/*
<span class='line'>  8</span>  * Permission is hereby granted, free of charge, to any person obtaining
<span class='line'>  9</span>  * a copy of this software and associated documentation files (the
<span class='line'> 10</span>  * "Software"), to deal in the Software without restriction, including
<span class='line'> 11</span>  * without limitation the rights to use, copy, modify, merge, publish,
<span class='line'> 12</span>  * distribute, sublicense, and/or sell copies of the Software, and to
<span class='line'> 13</span>  * permit persons to whom the Software is furnished to do so, subject to
<span class='line'> 14</span>  * the following conditions:
<span class='line'> 15</span>  * 
<span class='line'> 16</span>  * The above copyright notice and this permission notice shall be
<span class='line'> 17</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 18</span>  * 
<span class='line'> 19</span>  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
<span class='line'> 20</span>  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<span class='line'> 21</span>  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
<span class='line'> 22</span>  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
<span class='line'> 23</span>  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
<span class='line'> 24</span>  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
<span class='line'> 25</span>  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<span class='line'> 26</span>  * ====================================================================
<span class='line'> 27</span>  */</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> 
<span class='line'> 30</span> </span><span class="COMM">/**
<span class='line'> 31</span> Creates new jsPDF document object instance
<span class='line'> 32</span> @class
<span class='line'> 33</span> @param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
<span class='line'> 34</span> @param unit Measurement unit to be used when coordinates are specified. One of "pt" (points), "mm" (Default), "cm", "in"
<span class='line'> 35</span> @param format One of 'a3', 'a4' (Default),'a5' ,'letter' ,'legal'
<span class='line'> 36</span> @returns {jsPDF}
<span class='line'> 37</span> @name jsPDF
<span class='line'> 38</span> */</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jsPDF</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="STRN">'use strict'</span><span class="WHIT">
<span class='line'> 41</span> 
<span class='line'> 42</span> </span><span class="COMM">// this will run on &lt;=IE9, possibly some niche browsers</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="COMM">// new webkit-based, FireFox, IE10 already have native version of this.</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">btoa</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">btoa</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">		</span><span class="COMM">// DO NOT ADD UTF8 ENCODING CODE HERE!!!!</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">		</span><span class="COMM">// UTF8 encoding encodes bytes over char code 128</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">		</span><span class="COMM">// and, essentially, turns an 8-bit binary streams</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">		</span><span class="COMM">// (that base64 can deal with) into 7-bit binary streams. </span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">		</span><span class="COMM">// (by default server does not know that and does not recode the data back to 8bit)</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">		</span><span class="COMM">// You destroy your data.</span><span class="WHIT">
<span class='line'> 53</span> 
<span class='line'> 54</span> </span><span class="WHIT">		</span><span class="COMM">// binary streams like jpeg image data etc, while stored in JavaScript strings,</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">		</span><span class="COMM">// (which are 16bit arrays) are in 8bit format already.</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="COMM">// You do NOT need to char-encode that before base64 encoding.</span><span class="WHIT">
<span class='line'> 57</span> 
<span class='line'> 58</span> </span><span class="WHIT">		</span><span class="COMM">// if you, by act of fate</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">		</span><span class="COMM">// have string which has individual characters with code</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">		</span><span class="COMM">// above 255 (pure unicode chars), encode that BEFORE you base64 here.</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">		</span><span class="COMM">// you can use absolutely any approch there, as long as in the end,</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">		</span><span class="COMM">// base64 gets an 8bit (char codes 0 - 255) stream.</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="COMM">// when you get it on the server after un-base64, you must </span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">		</span><span class="COMM">// UNencode it too, to get back to 16, 32bit or whatever original bin stream.</span><span class="WHIT">
<span class='line'> 65</span> 
<span class='line'> 66</span> </span><span class="WHIT">		</span><span class="COMM">// Note, Yes, JavaScript strings are, in most cases UCS-2 - </span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">		</span><span class="COMM">// 16-bit character arrays. This does not mean, however,</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">		</span><span class="COMM">// that you always have to UTF8 it before base64.</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">		</span><span class="COMM">// it means that if you have actual characters anywhere in</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">		</span><span class="COMM">// that string that have char code above 255, you need to</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">		</span><span class="COMM">// recode *entire* string from 16-bit (or 32bit) to 8-bit array.</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">		</span><span class="COMM">// You can do binary split to UTF16 (BE or LE)</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">		</span><span class="COMM">// you can do utf8, you can split the thing by hand and prepend BOM to it,</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">		</span><span class="COMM">// but whatever you do, make sure you mirror the opposite on</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">		</span><span class="COMM">// the server. If server does not expect to post-process un-base64</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">		</span><span class="COMM">// 8-bit binary stream, think very very hard about messing around with encoding.</span><span class="WHIT">
<span class='line'> 77</span> 
<span class='line'> 78</span> </span><span class="WHIT">		</span><span class="COMM">// so, long story short:</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">		</span><span class="COMM">// DO NOT ADD UTF8 ENCODING CODE HERE!!!!</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">		
<span class='line'> 81</span> 		</span><span class="COMM">/* @preserve
<span class='line'> 82</span> 		====================================================================
<span class='line'> 83</span> 		base64 encoder
<span class='line'> 84</span> 		MIT, GPL
<span class='line'> 85</span> 	
<span class='line'> 86</span> 		version: 1109.2015
<span class='line'> 87</span> 		discuss at: http://phpjs.org/functions/base64_encode
<span class='line'> 88</span> 		+   original by: Tyler Akins (http://rumkin.com)
<span class='line'> 89</span> 		+   improved by: Bayron Guevara
<span class='line'> 90</span> 		+   improved by: Thunder.m
<span class='line'> 91</span> 		+   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
<span class='line'> 92</span> 		+   bugfixed by: Pellentesque Malesuada
<span class='line'> 93</span> 		+   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
<span class='line'> 94</span> 		+   improved by: Rafal Kukawski (http://kukawski.pl)
<span class='line'> 95</span> 		+   			 Daniel Dotsenko, Willow Systems Corp, willow-systems.com
<span class='line'> 96</span> 		====================================================================
<span class='line'> 97</span> 		*/</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">		
<span class='line'> 99</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b64</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">b64a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64.split</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bits</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">		</span><span class="NAME">ac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">		</span><span class="NAME">enc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">		</span><span class="NAME">tmp_arr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">	 
<span class='line'>106</span> 		</span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// pack three octets into four hexets</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">			</span><span class="NAME">o1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">			</span><span class="NAME">o2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">			</span><span class="NAME">o3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">	 
<span class='line'>111</span> 			</span><span class="NAME">bits</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o1</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">o2</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="WHIT"> </span><span class="NAME">o3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> 
<span class='line'>113</span> </span><span class="WHIT">			</span><span class="NAME">h1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bits</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">18</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">			</span><span class="NAME">h2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bits</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">12</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">			</span><span class="NAME">h3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bits</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">6</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">			</span><span class="NAME">h4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">bits</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="WHIT"> </span><span class="NUMB">0x3f</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">	 
<span class='line'>118</span> 			</span><span class="COMM">// use hexets to index into b64, and append result to encoded string</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">			</span><span class="NAME">tmp_arr</span><span class="PUNC">[</span><span class="NAME">ac</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64a</span><span class="PUNC">[</span><span class="NAME">h1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b64a</span><span class="PUNC">[</span><span class="NAME">h2</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b64a</span><span class="PUNC">[</span><span class="NAME">h3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b64a</span><span class="PUNC">[</span><span class="NAME">h4</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">data.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> 
<span class='line'>122</span> </span><span class="WHIT">		</span><span class="NAME">enc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp_arr.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.length</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">enc.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">enc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'==='</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="NAME">r</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> 
<span class='line'>126</span> </span><span class="WHIT">		</span><span class="COMM">// end of base64 encoder MIT, GPL</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>128</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>129</span> 
<span class='line'>130</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">getObjectLength</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Object.keys</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">	</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">object</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.keys</span><span class="PUNC">(</span><span class="NAME">object</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">	</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">object</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">object</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">object.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>139</span> 
<span class='line'>140</span> </span><span class="COMM">/**
<span class='line'>141</span> PubSub implementation
<span class='line'>142</span> 
<span class='line'>143</span> @class
<span class='line'>144</span> @name PubSub
<span class='line'>145</span> */</span><span class="WHIT">
<span class='line'>146</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">PubSub</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">	</span><span class="STRN">'use strict'</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">	</span><span class="COMM">/**  @preserve 
<span class='line'>149</span> 	-----------------------------------------------------------------------------------------------
<span class='line'>150</span> 	JavaScript PubSub library
<span class='line'>151</span> 	2012 (c) ddotsenko@willowsystems.com
<span class='line'>152</span> 	based on Peter Higgins (dante@dojotoolkit.org)
<span class='line'>153</span> 	Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
<span class='line'>154</span> 	Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
<span class='line'>155</span> 	http://dojofoundation.org/license for more information.
<span class='line'>156</span> 	-----------------------------------------------------------------------------------------------
<span class='line'>157</span> 	*/</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>159</span> 	@private
<span class='line'>160</span> 	@fieldOf PubSub
<span class='line'>161</span> 	*/</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">	</span><span class="NAME">this.topics</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>164</span> 	Stores what will be `this` within the callback functions.
<span class='line'>165</span> 
<span class='line'>166</span> 	@private
<span class='line'>167</span> 	@fieldOf PubSub#
<span class='line'>168</span> 	*/</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">	</span><span class="NAME">this.context</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">context</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>171</span> 	Allows caller to emit an event and pass arguments to event listeners.
<span class='line'>172</span> 	@public
<span class='line'>173</span> 	@function
<span class='line'>174</span> 	@param topic {String} Name of the channel on which to voice this event
<span class='line'>175</span> 	@param **args Any number of arguments you want to pass to the listeners of this event.
<span class='line'>176</span> 	@methodOf PubSub#
<span class='line'>177</span> 	@name publish
<span class='line'>178</span> 	*/</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">	</span><span class="NAME">this.publish</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">topic</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">		</span><span class="STRN">'use strict'</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">topic</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">currentTopic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">topic</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toremove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pair</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">currentTopic.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">				</span><span class="NAME">pair</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">currentTopic</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// this is a [function, once_flag] array</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">				</span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pair</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> 
<span class='line'>192</span> 				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pair</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">/* 'run once' flag set */</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">				  </span><span class="NAME">pair</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">				  </span><span class="NAME">toremove.push</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">			   	</span><span class="NAME">fn.apply</span><span class="PUNC">(</span><span class="NAME">this.context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">toremove.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">			  </span><span class="NAME">currentTopic.splice</span><span class="PUNC">(</span><span class="NAME">toremove</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>204</span> 	Allows listener code to subscribe to channel and be called when data is available 
<span class='line'>205</span> 	@public
<span class='line'>206</span> 	@function
<span class='line'>207</span> 	@param topic {String} Name of the channel on which to voice this event
<span class='line'>208</span> 	@param callback {Function} Executable (function pointer) that will be ran when event is voiced on this channel.
<span class='line'>209</span> 	@param once {Boolean} (optional. False by default) Flag indicating if the function is to be triggered only once.
<span class='line'>210</span> 	@returns {Object} A token object that cen be used for unsubscribing.  
<span class='line'>211</span> 	@methodOf PubSub#
<span class='line'>212</span> 	@name subscribe
<span class='line'>213</span> 	*/</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">	</span><span class="NAME">this.subscribe</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">topic</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">once</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">		</span><span class="STRN">'use strict'</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">topic</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">			</span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">topic</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">[</span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">once</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">			</span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">topic</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">callback</span><span class="PUNC">,</span><span class="NAME">once</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">			</span><span class="STRN">"topic"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">topic</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">			</span><span class="STRN">"callback"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>227</span> 	Allows listener code to unsubscribe from a channel 
<span class='line'>228</span> 	@public
<span class='line'>229</span> 	@function
<span class='line'>230</span> 	@param token {Object} A token object that was returned by `subscribe` method 
<span class='line'>231</span> 	@methodOf PubSub#
<span class='line'>232</span> 	@name unsubscribe
<span class='line'>233</span> 	*/</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">	</span><span class="NAME">this.unsubscribe</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">token.topic</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">currentTopic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.topics</span><span class="PUNC">[</span><span class="NAME">token.topic</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">			
<span class='line'>238</span> 			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">currentTopic.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">currentTopic</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">token.callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">					</span><span class="NAME">currentTopic.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>245</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>246</span> 
<span class='line'>247</span> </span><span class="WHIT">	
<span class='line'>248</span> </span><span class="COMM">/**
<span class='line'>249</span> @constructor
<span class='line'>250</span> @private
<span class='line'>251</span> */</span><span class="WHIT">
<span class='line'>252</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">jsPDF</span><span class="PUNC">(</span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">/** String */</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>253</span> 
<span class='line'>254</span> </span><span class="WHIT">	</span><span class="COMM">// Default parameter values</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">	</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">orientation.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'mm'</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'a4'</span><span class="WHIT">
<span class='line'>259</span> 
<span class='line'>260</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">format_as_string</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'20120619'</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pdfVersion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'1.3'</span><span class="WHIT"> </span><span class="COMM">// PDF Version</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// Size in pt of various paper formats</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">		</span><span class="STRN">'a3'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">841.89</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1190.55</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a4'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">595.28</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">841.89</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a5'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">420.94</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">595.28</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'letter'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">612</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">792</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'legal'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">612</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1008</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0 g'</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">drawColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'0 G'</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">page</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="COMM">// 'n' Current object number</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="COMM">// switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">offsets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// collection of font objects, where key is fontKey - a dynamically created label for a given font.</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontmap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// mapping structure fontName > fontStyle > font key - performance layer. See addFont()</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">activeFontSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">activeFontKey</span><span class="WHIT"> </span><span class="COMM">// will be string representing the KEY of the font as combination of fontName + fontStyle</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lineWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0.200025</span><span class="WHIT"> </span><span class="COMM">// 2mm</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="COMM">// Scale factor</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">documentProperties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'title'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">,</span><span class="STRN">'subject'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">,</span><span class="STRN">'author'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">,</span><span class="STRN">'keywords'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">,</span><span class="STRN">'creator'</span><span class="PUNC">:</span><span class="STRN">''</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lineCapID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lineJoinID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">API</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">events</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">PubSub</span><span class="PUNC">(</span><span class="NAME">API</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>293</span> 
<span class='line'>294</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'pt'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'mm'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="PUNC">/</span><span class="NUMB">25.4</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'cm'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="PUNC">/</span><span class="NUMB">2.54</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">unit</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'in'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">		</span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">72</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">		</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid unit: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">unit</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">	
<span class='line'>306</span> 	</span><span class="COMM">// Dimensions are stored as user units and converted to points on output</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">format_as_string</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">		</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">[</span><span class="NAME">format_as_string</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">		</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageFormats</span><span class="PUNC">[</span><span class="NAME">format_as_string</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">		</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">			</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">			</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>315</span> 		</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid format: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">	
<span class='line'>320</span> 	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'portrait'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">		</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'l'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'landscape'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>323</span> </span><span class="WHIT">		</span><span class="NAME">orientation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'l'</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">		</span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">		</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">		</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">'Invalid orientation: '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">orientation</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>330</span> 
<span class='line'>331</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">	</span><span class="COMM">// Private functions</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">	</span><span class="COMM">// simplified (speedier) replacement for sprintf's %.2f conversion  </span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">number.toFixed</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">	</span><span class="COMM">// simplified (speedier) replacement for sprintf's %.3f conversion  </span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">number.toFixed</span><span class="PUNC">(</span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">	</span><span class="COMM">// simplified (speedier) replacement for sprintf's %02d</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toFixed</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">number</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">	</span><span class="COMM">// simplified (speedier) replacement for sprintf's %02d</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd10</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">number</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toFixed</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.length</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NUMB">11</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">n.length</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">		</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">out</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="COMM">/* set by beginPage */</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">			</span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">page</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">			</span><span class="NAME">content.push</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">			</span><span class="NAME">content_length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">string.length</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="COMM">// +1 is for '\n' that will be used to join contents of content </span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">		</span><span class="COMM">// Begin a new object</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">		</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NAME">objectNumber</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 obj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>367</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">wPt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageWidth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hPt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT">
<span class='line'>372</span> 
<span class='line'>373</span> </span><span class="WHIT">		</span><span class="COMM">// outToPages = false as set in endDocument(). out() writes to content.</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">		
<span class='line'>375</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">			</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Type /Page'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Parent 1 0 R'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'>380</span> 			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Resources 2 0 R'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Contents '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">			
<span class='line'>384</span> 			</span><span class="COMM">// Page content</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">			</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">			</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Length '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">p.length</span><span class="WHIT">  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">			</span><span class="NAME">putStream</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>389</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'1 0 obj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/Type /Pages'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'/Kids ['</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">			</span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">3</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R '</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">kids</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Count '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">page</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/MediaBox [0 0 '</span><span class="PUNC">+</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">wPt</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">' '</span><span class="PUNC">+</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">hPt</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">']'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">		
<span class='line'>403</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putStream</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'stream'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endstream'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putResources</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">		</span><span class="NAME">putFonts</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">		</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'putResources'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">		</span><span class="COMM">// Resource dictionary</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'2 0 obj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">		</span><span class="NAME">putResourceDictionary</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>420</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putFonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fonts.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">fontKey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">				</span><span class="NAME">putFont</span><span class="PUNC">(</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">fontKey</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>426</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">font</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">		</span><span class="NAME">font.objectNumber</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;/BaseFont/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">font.PostScriptName</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/Type/Font'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">font.encoding</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Encoding/'</span><span class="PUNC">+</span><span class="NAME">font.encoding</span><span class="PUNC">)</span><span class="WHIT">			
<span class='line'>432</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Subtype/Type1>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">addToFontDictionary</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fontKey</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">		</span><span class="COMM">// this is mapping structure for quick font key lookup.</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">		</span><span class="COMM">// returns the KEY of the font (ex: "F1") for a given pair of font name and type (ex: "Arial". "Italic")</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT">			</span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="COMM">// fontStyle is a var interpreted and converted to appropriate string. don't wrap in quotes.</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">		</span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">fontStyle</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>446</span> 	FontObject describes a particular font as member of an instnace of jsPDF
<span class='line'>447</span> 
<span class='line'>448</span> 	It's a collection of properties like 'id' (to be used in PDF stream),
<span class='line'>449</span> 	'fontName' (font's family name), 'fontStyle' (font's style variant label)
<span class='line'>450</span> 
<span class='line'>451</span> 	@class
<span class='line'>452</span> 	@public
<span class='line'>453</span> 	@property id {String} PDF-document-instance-specific label assinged to the font.
<span class='line'>454</span> 	@property PostScriptName {String} PDF specification full name for the font
<span class='line'>455</span> 	@property encoding {Object} Encoding_name-to-Font_metrics_object mapping.
<span class='line'>456</span> 	@name FontObject
<span class='line'>457</span> 	*/</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">FontObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">addFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">PostScriptName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'F'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">getObjectLength</span><span class="PUNC">(</span><span class="NAME">fonts</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">		
<span class='line'>462</span> 		</span><span class="COMM">// This is FontObject </span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">font</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">fontKey</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT">			</span><span class="STRN">'id'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">			</span><span class="COMM">// , 'objectNumber':   will be set by putFont()</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'PostScriptName'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">PostScriptName</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'fontName'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'fontStyle'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'encoding'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'metadata'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>472</span> 
<span class='line'>473</span> </span><span class="WHIT">		</span><span class="NAME">addToFontDictionary</span><span class="PUNC">(</span><span class="NAME">fontKey</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>474</span> 
<span class='line'>475</span> </span><span class="WHIT">		</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'addFont'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">font</span><span class="PUNC">)</span><span class="WHIT">		
<span class='line'>476</span> 
<span class='line'>477</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">addFonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>480</span> 
<span class='line'>481</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"helvetica"</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"times"</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"courier"</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"normal"</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"bold"</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"italic"</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"bolditalic"</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'StandardEncoding'</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">standardFonts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">			</span><span class="PUNC">[</span><span class="STRN">'Helvetica'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Helvetica-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Helvetica-Oblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Helvetica-BoldOblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">HELVETICA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Courier'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Courier-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Courier-Oblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Courier-BoldOblique'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">COURIER</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Times-Roman'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">NORMAL</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Times-Bold'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Times-Italic'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Times-BoldItalic'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TIMES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">BOLD_ITALIC</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>503</span> 
<span class='line'>504</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parts</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">standardFonts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">			</span><span class="NAME">fontKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">addFont</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">				</span><span class="NAME">standardFonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">standardFonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">standardFonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encoding</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">			</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>512</span> 
<span class='line'>513</span> </span><span class="WHIT">			</span><span class="COMM">// adding aliases for standard fonts, this time matching the capitalization</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">			</span><span class="NAME">parts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">standardFonts</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">'-'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">			</span><span class="NAME">addToFontDictionary</span><span class="PUNC">(</span><span class="NAME">fontKey</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parts</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">parts</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>517</span> 
<span class='line'>518</span> </span><span class="WHIT">		</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'addFonts'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'fonts'</span><span class="PUNC">:</span><span class="NAME">fonts</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'dictionary'</span><span class="PUNC">:</span><span class="NAME">fontmap</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putResourceDictionary</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Font &lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>523</span> </span><span class="WHIT">		</span><span class="COMM">// Do this for each font, the '1' bit is the index of the font</span><span class="WHIT">
<span class='line'>524</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fonts.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">fontKey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">				</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fontKey</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">fontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/XObject &lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">		</span><span class="NAME">putXobjectDict</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putXobjectDict</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">		</span><span class="COMM">// Loop through images, or other data objects</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">		</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'putXobjectDict'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Producer (jsPDF '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.title</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Title ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.title</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.subject</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Subject ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.subject</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.author</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Author ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.author</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.keywords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Keywords ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.keywords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">documentProperties.creator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Creator ('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">documentProperties.creator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>554</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">		
<span class='line'>555</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">created</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/CreationDate (D:'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>557</span> 			</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>558</span> </span><span class="WHIT">				</span><span class="NAME">created.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="PUNC">(</span><span class="NAME">created.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="PUNC">(</span><span class="NAME">created.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>561</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="PUNC">(</span><span class="NAME">created.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="PUNC">(</span><span class="NAME">created.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">padd2</span><span class="PUNC">(</span><span class="NAME">created.getSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">			</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">			</span><span class="STRN">')'</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">		</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>567</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>568</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putCatalog</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Type /Catalog'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Pages 1 0 R'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT">		</span><span class="COMM">// @TODO: Add zoom and layout modes</span><span class="WHIT">
<span class='line'>572</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/OpenAction [3 0 R /FitH null]'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/PageLayout /OneColumn'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>574</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>575</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">putTrailer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>576</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Size '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>577</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Root '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>578</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'/Info '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 0 R'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>579</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">	
<span class='line'>580</span> 	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">beginPage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>581</span> </span><span class="WHIT">		</span><span class="NAME">page</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT">		</span><span class="COMM">// Do dimension stuff</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>584</span> </span><span class="WHIT">		</span><span class="NAME">pages</span><span class="PUNC">[</span><span class="NAME">page</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>585</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>586</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_addPage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">		</span><span class="NAME">beginPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">		</span><span class="COMM">// Set line width</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">lineWidth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' w'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>590</span> </span><span class="WHIT">		</span><span class="COMM">// Set draw color</span><span class="WHIT">
<span class='line'>591</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">drawColor</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>592</span> </span><span class="WHIT">		</span><span class="COMM">// resurrecting non-default line caps, joins</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lineCapID</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">lineCapID.toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">' J'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lineJoinID</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">lineJoinID.toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">' j'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>595</span> 
<span class='line'>596</span> </span><span class="WHIT">		</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'addPage'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'pageNumber'</span><span class="PUNC">:</span><span class="NAME">page</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>598</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>599</span> 	Returns a document-specific font key - a label assigned to a
<span class='line'>600</span> 	font name + font type combination at the time the font was added
<span class='line'>601</span> 	to the font inventory.
<span class='line'>602</span> 
<span class='line'>603</span> 	Font key is used as label for the desired font for a block of text
<span class='line'>604</span> 	to be added to the PDF document stream.
<span class='line'>605</span> 	@private
<span class='line'>606</span> 	@function
<span class='line'>607</span> 	@param fontName {String} can be undefined on "falthy" to indicate "use current"
<span class='line'>608</span> 	@param fontStyle {String} can be undefined on "falthy" to indicate "use current"
<span class='line'>609</span> 	@returns {String} Font key.
<span class='line'>610</span> 	*/</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">getFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>613</span> 
<span class='line'>614</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT">			</span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'fontName'</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>617</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontStyle</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT">			</span><span class="NAME">fontStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="STRN">'fontStyle'</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>620</span> 
<span class='line'>621</span> </span><span class="WHIT">		</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>622</span> </span><span class="WHIT">			</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">fontStyle</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// returns a string like 'F3' - the KEY corresponding tot he font + type combination.</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">			</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>626</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Unable to look up font label for font '"</span><span class="PUNC">+</span><span class="NAME">fontName</span><span class="PUNC">+</span><span class="STRN">"', '"</span><span class="PUNC">+</span><span class="NAME">fontStyle</span><span class="PUNC">+</span><span class="STRN">"'. Refer to getFontList() for available fonts."</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>629</span> 
<span class='line'>630</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">buildDocument</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT">		
<span class='line'>634</span> 		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT"> </span><span class="COMM">// switches out() to content</span><span class="WHIT">
<span class='line'>635</span> </span><span class="WHIT">		</span><span class="NAME">content</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>636</span> </span><span class="WHIT">		</span><span class="NAME">offsets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">		
<span class='line'>638</span> 		</span><span class="COMM">// putHeader()</span><span class="WHIT">
<span class='line'>639</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'%PDF-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pdfVersion</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>640</span> </span><span class="WHIT">		
<span class='line'>641</span> 		</span><span class="NAME">putPages</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>642</span> </span><span class="WHIT">		
<span class='line'>643</span> 		</span><span class="NAME">putResources</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>644</span> 
<span class='line'>645</span> </span><span class="WHIT">		</span><span class="COMM">// Info</span><span class="WHIT">
<span class='line'>646</span> </span><span class="WHIT">		</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>647</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>648</span> </span><span class="WHIT">		</span><span class="NAME">putInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>649</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>650</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>651</span> </span><span class="WHIT">		
<span class='line'>652</span> 		</span><span class="COMM">// Catalog</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">		</span><span class="NAME">newObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT">		</span><span class="NAME">putCatalog</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'endobj'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>658</span> </span><span class="WHIT">		
<span class='line'>659</span> 		</span><span class="COMM">// Cross-ref</span><span class="WHIT">
<span class='line'>660</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">content_length</span><span class="WHIT">
<span class='line'>661</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'xref'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>662</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'0 '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">objectNumber</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'0000000000 65535 f '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">objectNumber</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">padd10</span><span class="PUNC">(</span><span class="NAME">offsets</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' 00000 n '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">		</span><span class="COMM">// Trailer</span><span class="WHIT">
<span class='line'>668</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'trailer'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>669</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'&lt;&lt;'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>670</span> </span><span class="WHIT">		</span><span class="NAME">putTrailer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>671</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'>>'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>672</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'startxref'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>673</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>674</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="STRN">'%%EOF'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">		
<span class='line'>676</span> 		</span><span class="NAME">outToPages</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">		
<span class='line'>678</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">content.join</span><span class="PUNC">(</span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>681</span> 	
<span class='line'>682</span> 	@public
<span class='line'>683</span> 	@function
<span class='line'>684</span> 	@param text {String} 
<span class='line'>685</span> 	@param flags {Object} Encoding flags.
<span class='line'>686</span> 	@returns {String} Encoded string
<span class='line'>687</span> 	*/</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">to8bitStream</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT">		</span><span class="COMM">/* PDF 1.3 spec:
<span class='line'>690</span> 		"For text strings encoded in Unicode, the first two bytes must be 254 followed by
<span class='line'>691</span> 		255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts
<span class='line'>692</span> 		with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely
<span class='line'>693</span> 		to be a meaningful beginning of a word or phrase.) The remainder of the
<span class='line'>694</span> 		string consists of Unicode character codes, according to the UTF-16 encoding
<span class='line'>695</span> 		specified in the Unicode standard, version 2.0. Commonly used Unicode values
<span class='line'>696</span> 		are represented as 2 bytes per character, with the high-order byte appearing first
<span class='line'>697</span> 		in the string."
<span class='line'>698</span> 
<span class='line'>699</span> 		In other words, if there are chars in a string with char code above 255, we
<span class='line'>700</span> 		recode the string to UCS2 BE - string doubles in length and BOM is prepended.
<span class='line'>701</span> 
<span class='line'>702</span> 		HOWEVER!
<span class='line'>703</span> 		Actual *content* (body) text (as opposed to strings used in document properties etc)
<span class='line'>704</span> 		does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)
<span class='line'>705</span> 
<span class='line'>706</span> 		Because of Adobe's focus on "you subset your fonts!" you are not supposed to have
<span class='line'>707</span> 		a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could
<span class='line'>708</span> 		fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode
<span class='line'>709</span> 		code page. There, however, all characters in the stream are treated as GIDs,
<span class='line'>710</span> 		including BOM, which is the reason we need to skip BOM in content text (i.e. that
<span class='line'>711</span> 		that is tied to a font).
<span class='line'>712</span> 
<span class='line'>713</span> 		To signal this "special" PDFEscape / to8bitStream handling mode,
<span class='line'>714</span> 		API.text() function sets (unless you overwrite it with manual values
<span class='line'>715</span> 		given to API.text(.., flags) )
<span class='line'>716</span> 			flags.autoencode = true
<span class='line'>717</span> 			flags.noBOM = true
<span class='line'>718</span> 
<span class='line'>719</span> 		*/</span><span class="WHIT">
<span class='line'>720</span> 
<span class='line'>721</span> </span><span class="WHIT">		</span><span class="COMM">/*
<span class='line'>722</span> 		`flags` properties relied upon:
<span class='line'>723</span> 		.sourceEncoding = string with encoding label. 
<span class='line'>724</span> 			"Unicode" by default. = encoding of the incoming text.
<span class='line'>725</span> 			pass some non-existing encoding name 
<span class='line'>726</span> 			(ex: 'Do not touch my strings! I know what I am doing.')
<span class='line'>727</span> 			to make encoding code skip the encoding step.
<span class='line'>728</span> 		.outputEncoding = Either valid PDF encoding name 
<span class='line'>729</span> 			(must be supported by jsPDF font metrics, otherwise no encoding)
<span class='line'>730</span> 			or a JS object, where key = sourceCharCode, value = outputCharCode
<span class='line'>731</span> 			missing keys will be treated as: sourceCharCode === outputCharCode
<span class='line'>732</span> 		.noBOM
<span class='line'>733</span> 			See comment higher above for explanation for why this is important
<span class='line'>734</span> 		.autoencode
<span class='line'>735</span> 			See comment higher above for explanation for why this is important
<span class='line'>736</span> 		*/</span><span class="WHIT">
<span class='line'>737</span> 
<span class='line'>738</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>739</span> 
<span class='line'>740</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flags</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>741</span> </span><span class="WHIT">			</span><span class="NAME">flags</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>742</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>743</span> 
<span class='line'>744</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sourceEncoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flags.sourceEncoding</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sourceEncoding</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Unicode'</span><span class="WHIT">
<span class='line'>745</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">encodingBlock</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flags.outputEncoding</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isUnicode</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bch</span><span class="WHIT">
<span class='line'>749</span> </span><span class="WHIT">		</span><span class="COMM">// This 'encoding' section relies on font metrics format </span><span class="WHIT">
<span class='line'>750</span> </span><span class="WHIT">		</span><span class="COMM">// attached to font objects by, among others, </span><span class="WHIT">
<span class='line'>751</span> </span><span class="WHIT">		</span><span class="COMM">// "Willow Systems' standard_font_metrics plugin"</span><span class="WHIT">
<span class='line'>752</span> </span><span class="WHIT">		</span><span class="COMM">// see jspdf.plugin.standard_font_metrics.js for format</span><span class="WHIT">
<span class='line'>753</span> </span><span class="WHIT">		</span><span class="COMM">// of the font.metadata.encoding Object.</span><span class="WHIT">
<span class='line'>754</span> </span><span class="WHIT">		</span><span class="COMM">// It should be something like</span><span class="WHIT">
<span class='line'>755</span> </span><span class="WHIT">		</span><span class="COMM">//   .encoding = {'codePages':['WinANSI....'], 'WinANSI...':{code:code, ...}}</span><span class="WHIT">
<span class='line'>756</span> </span><span class="WHIT">		</span><span class="COMM">//   .widths = {0:width, code:width, ..., 'fof':divisor}</span><span class="WHIT">
<span class='line'>757</span> </span><span class="WHIT">		</span><span class="COMM">//   .kerning = {code:{previous_char_code:shift, ..., 'fof':-divisor},...}</span><span class="WHIT">
<span class='line'>758</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">flags.autoencode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>759</span> 			</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">metadata</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT">			</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">metadata</span><span class="PUNC">[</span><span class="NAME">sourceEncoding</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT">			</span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">metadata</span><span class="PUNC">[</span><span class="NAME">sourceEncoding</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">encoding</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT">		</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">			</span><span class="NAME">encodingBlock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">metadata</span><span class="PUNC">[</span><span class="NAME">sourceEncoding</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">encoding</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT">			
<span class='line'>765</span> 			</span><span class="COMM">// each font has default encoding. Some have it clearly defined.</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">encoding</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">				</span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">activeFontKey</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">encoding</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>769</span> 
<span class='line'>770</span> </span><span class="WHIT">			</span><span class="COMM">// Hmmm, the above did not work? Let's try again, in different place.</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">encodingBlock.codePages</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">				</span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodingBlock.codePages</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// let's say, first one is the default</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>774</span> 
<span class='line'>775</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">				</span><span class="NAME">outputEncoding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">encodingBlock</span><span class="PUNC">[</span><span class="NAME">outputEncoding</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">			</span><span class="COMM">// we want output encoding to be a JS Object, where</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">			</span><span class="COMM">// key = sourceEncoding's character code and </span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">			</span><span class="COMM">// value = outputEncoding's character code.</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">outputEncoding</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT">				</span><span class="NAME">isUnicode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT">				</span><span class="NAME">newtext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT">				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">					</span><span class="NAME">ch</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">outputEncoding</span><span class="PUNC">[</span><span class="NAME">text.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ch</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT">						</span><span class="NAME">newtext.push</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>788</span> </span><span class="WHIT">							</span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">ch</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>789</span> </span><span class="WHIT">						</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>790</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>791</span> </span><span class="WHIT">						</span><span class="NAME">newtext.push</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>792</span> </span><span class="WHIT">							</span><span class="NAME">text</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>793</span> </span><span class="WHIT">						</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>794</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>795</span> 
<span class='line'>796</span> </span><span class="WHIT">					</span><span class="COMM">// since we are looping over chars anyway, might as well</span><span class="WHIT">
<span class='line'>797</span> </span><span class="WHIT">					</span><span class="COMM">// check for residual unicodeness</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">newtext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="COMM">/* more than 255 */</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">						</span><span class="NAME">isUnicode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT">				</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newtext.join</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>804</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>805</span> 
<span class='line'>806</span> </span><span class="WHIT">		</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="WHIT">
<span class='line'>807</span> </span><span class="WHIT">		</span><span class="COMM">// isUnicode may be set to false above. Hence the triple-equal to undefined</span><span class="WHIT">
<span class='line'>808</span> </span><span class="WHIT">		</span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isUnicode</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>809</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="COMM">/* more than 255 */</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT">				</span><span class="NAME">isUnicode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">			</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isUnicode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">			</span><span class="NAME">newtext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">flags.noBOM</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">254</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">255</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">				</span><span class="NAME">ch</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.charCodeAt</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">				</span><span class="NAME">bch</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ch</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="COMM">// divide by 256</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bch</span><span class="WHIT"> </span><span class="PUNC">>></span><span class="WHIT"> </span><span class="NUMB">8</span><span class="WHIT"> </span><span class="COMM">/* something left after dividing by 256 second time */</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">					</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Character at position "</span><span class="PUNC">+</span><span class="NAME">i.toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="STRN">" of string '"</span><span class="PUNC">+</span><span class="NAME">text</span><span class="PUNC">+</span><span class="STRN">"' exceeds 16bits. Cannot be encoded into UCS-2 BE"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">				</span><span class="NAME">newtext.push</span><span class="PUNC">(</span><span class="NAME">bch</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">				</span><span class="NAME">newtext.push</span><span class="PUNC">(</span><span class="NAME">ch</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">bch</span><span class="WHIT"> </span><span class="PUNC">&lt;&lt;</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode.apply</span><span class="PUNC">(</span><span class="NAME">undef</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>828</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>829</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT">	</span><span class="COMM">// Replace '/', '(', and ')' with pdf-safe versions</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>832</span> </span><span class="WHIT">		</span><span class="COMM">// doing to8bitStream does NOT make this PDF display unicode text. For that</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT">		</span><span class="COMM">// we also need to reference a unicode font and embed it - royal pain in the rear.</span><span class="WHIT">
<span class='line'>834</span> 
<span class='line'>835</span> </span><span class="WHIT">		</span><span class="COMM">// There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,</span><span class="WHIT">
<span class='line'>836</span> </span><span class="WHIT">		</span><span class="COMM">// which JavaScript Strings are happy to provide. So, while we still cannot display</span><span class="WHIT">
<span class='line'>837</span> </span><span class="WHIT">		</span><span class="COMM">// 2-byte characters property, at least CONDITIONALLY converting (entire string containing) </span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT">		</span><span class="COMM">// 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT">		</span><span class="COMM">// is still parseable.</span><span class="WHIT">
<span class='line'>840</span> </span><span class="WHIT">		</span><span class="COMM">// This will allow immediate support for unicode in document properties strings.</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">to8bitStream</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\\/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\\\'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\(/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\('</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\)/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'\\)'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">	</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">getStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">		</span><span class="COMM">// see Path-Painting Operators of PDF spec</span><span class="WHIT">
<span class='line'>845</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'S'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// stroke</span><span class="WHIT">
<span class='line'>846</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'F'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">			</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// fill</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'FD'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'DF'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">			</span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'B'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// both</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>851</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">op</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">	
<span class='line'>854</span> 
<span class='line'>855</span> 	</span><span class="COMM">//---------------------------------------</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">	</span><span class="COMM">// Public API</span><span class="WHIT">
<span class='line'>857</span> 
<span class='line'>858</span> </span><span class="WHIT">	</span><span class="COMM">/*
<span class='line'>859</span> 	Object exposing internal API to plugins
<span class='line'>860</span> 	@public
<span class='line'>861</span> 	*/</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">	</span><span class="NAME">API.internal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>863</span> </span><span class="WHIT">		</span><span class="STRN">'pdfEscape'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="WHIT">
<span class='line'>864</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'getStyle'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">getStyle</span><span class="WHIT">
<span class='line'>865</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>866</span> 		Returns {FontObject} describing a particular font.
<span class='line'>867</span> 		@public
<span class='line'>868</span> 		@function
<span class='line'>869</span> 		@param fontName {String} (Optional) Font's family name
<span class='line'>870</span> 		@param fontStyle {String} (Optional) Font's style variation name (Example:"Italic")
<span class='line'>871</span> 		@returns {FontObject}
<span class='line'>872</span> 		*/</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'getFont'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fonts</span><span class="PUNC">[</span><span class="NAME">getFont.apply</span><span class="PUNC">(</span><span class="NAME">API</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>874</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'getFontSize'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">activeFontSize</span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>875</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'btoa'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">btoa</span><span class="WHIT">
<span class='line'>876</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'write'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">string1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">string2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">string3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">etc</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>877</span> </span><span class="WHIT">			</span><span class="NAME">out</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>878</span> </span><span class="WHIT">				</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">?</span><span class="WHIT"> 
<span class='line'>879</span> 				</span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> 
<span class='line'>880</span> 				</span><span class="NAME">Array.prototype.join.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>881</span> </span><span class="WHIT">			</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>882</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>883</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'getCoordinateString'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>884</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>885</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>886</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'getVerticalCoordinateString'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>887</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'collections'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'newObject'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">newObject</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'putStream'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">putStream</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'events'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">events</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT">		</span><span class="COMM">// ratio that you use in multiplication of a given "size" number to arrive to 'point' </span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT">		</span><span class="COMM">// units of measurement.</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">		</span><span class="COMM">// scaleFactor is set at initialization of the document and calculated against the stated </span><span class="WHIT">
<span class='line'>896</span> </span><span class="WHIT">		</span><span class="COMM">// default measurement units for the document.</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT">		</span><span class="COMM">// If default is "mm", k is the number that will turn number in 'mm' into 'points' number.</span><span class="WHIT">
<span class='line'>898</span> </span><span class="WHIT">		</span><span class="COMM">// through multiplication.</span><span class="WHIT">
<span class='line'>899</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'scaleFactor'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> 
<span class='line'>900</span> 		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'pageSize'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'width'</span><span class="PUNC">:</span><span class="NAME">pageWidth</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'height'</span><span class="PUNC">:</span><span class="NAME">pageHeight</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>902</span> </span><span class="WHIT">	
<span class='line'>903</span> 	</span><span class="COMM">/**
<span class='line'>904</span> 	Adds (and transfers the focus to) new page to the PDF document.
<span class='line'>905</span> 	@function
<span class='line'>906</span> 	@returns {jsPDF} 
<span class='line'>907</span> 
<span class='line'>908</span> 	@methodOf jsPDF#
<span class='line'>909</span> 	@name addPage
<span class='line'>910</span> 	 */</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT">	</span><span class="NAME">API.addPage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT">		</span><span class="NAME">_addPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>914</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>915</span> 
<span class='line'>916</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>917</span> 	Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings. 
<span class='line'>918</span> 	@function
<span class='line'>919</span> 	@param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
<span class='line'>920</span> 	@param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>921</span> 	@param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>922</span> 	@param {Object} flags Collection of settings signalling how the text must be encoded. Defaults are sane. If you think you want to pass some flags, you likely can read the source.
<span class='line'>923</span> 	@returns {jsPDF}
<span class='line'>924</span> 	@methodOf jsPDF#
<span class='line'>925</span> 	@name text
<span class='line'>926</span> 	 */</span><span class="WHIT">
<span class='line'>927</span> </span><span class="WHIT">	</span><span class="NAME">API.text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>928</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'>929</span> 		 * Inserts something like this into PDF
<span class='line'>930</span> 			BT 
<span class='line'>931</span> 			/F1 16 Tf  % Font name + size
<span class='line'>932</span> 			16 TL % How many units down for next line in multiline text
<span class='line'>933</span> 			0 g % color
<span class='line'>934</span> 			28.35 813.54 Td % position
<span class='line'>935</span> 			(line one) Tj 
<span class='line'>936</span> 			T* (line two) Tj
<span class='line'>937</span> 			T* (line three) Tj
<span class='line'>938</span> 			ET
<span class='line'>939</span> 	 	*/</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT">		
<span class='line'>941</span> 	 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>942</span> </span><span class="WHIT">		</span><span class="COMM">// Pre-August-2012 the order of arguments was function(x, y, text, flags)</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT">		</span><span class="COMM">// in effort to make all calls have similar signature like </span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT">		</span><span class="COMM">//   function(data, coordinates... , miscellaneous)</span><span class="WHIT">
<span class='line'>945</span> </span><span class="WHIT">		</span><span class="COMM">// this method had its args flipped.</span><span class="WHIT">
<span class='line'>946</span> </span><span class="WHIT">		</span><span class="COMM">// code below allows backward compatibility with old arg order.</span><span class="WHIT">
<span class='line'>947</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_first</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_second</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_third</span><span class="WHIT">
<span class='line'>948</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT">			</span><span class="NAME">_first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT">			</span><span class="NAME">_second</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>951</span> </span><span class="WHIT">			</span><span class="NAME">_third</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>952</span> 
<span class='line'>953</span> </span><span class="WHIT">			</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_first</span><span class="WHIT"> 
<span class='line'>954</span> 			</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_second</span><span class="WHIT"> 
<span class='line'>955</span> 			</span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_third</span><span class="WHIT">
<span class='line'>956</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>957</span> 
<span class='line'>958</span> </span><span class="WHIT">		</span><span class="COMM">// If there are any newlines in text, we assume</span><span class="WHIT">
<span class='line'>959</span> </span><span class="WHIT">		</span><span class="COMM">// the user wanted to print multiple lines, so break the</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT">		</span><span class="COMM">// text up into an array.  If the text is already an array,</span><span class="WHIT">
<span class='line'>961</span> </span><span class="WHIT">		</span><span class="COMM">// we assume the user knows what they are doing.</span><span class="WHIT">
<span class='line'>962</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">text.match</span><span class="PUNC">(</span><span class="REGX">/[\n\r]/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>963</span> </span><span class="WHIT">			</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.split</span><span class="PUNC">(</span><span class="REGX">/\r\n|\r|\n/g</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>964</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>965</span> 
<span class='line'>966</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>967</span> </span><span class="WHIT">			</span><span class="NAME">flags</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'noBOM'</span><span class="PUNC">:</span><span class="KEYW">true</span><span class="PUNC">,</span><span class="STRN">'autoencode'</span><span class="PUNC">:</span><span class="KEYW">true</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>968</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>969</span> 
<span class='line'>970</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flags.noBOM</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>971</span> </span><span class="WHIT">				</span><span class="NAME">flags.noBOM</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>972</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>973</span> 
<span class='line'>974</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">flags.autoencode</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>975</span> </span><span class="WHIT">				</span><span class="NAME">flags.autoencode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>976</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>977</span> 
<span class='line'>978</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>979</span> 
<span class='line'>980</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT">
<span class='line'>981</span> 
<span class='line'>982</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>983</span> </span><span class="WHIT">			</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>984</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">text</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="COMM">/* Array */</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>985</span> </span><span class="WHIT">			</span><span class="COMM">// we don't want to destroy  original text array, so cloning it</span><span class="WHIT">
<span class='line'>986</span> </span><span class="WHIT">			</span><span class="NAME">newtext</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.concat</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>987</span> </span><span class="WHIT">			</span><span class="COMM">// we do array.join('text that must not be PDFescaped")</span><span class="WHIT">
<span class='line'>988</span> </span><span class="WHIT">			</span><span class="COMM">// thus, pdfEscape each component separately</span><span class="WHIT">
<span class='line'>989</span> </span><span class="WHIT">			</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newtext.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>990</span> </span><span class="WHIT">				</span><span class="NAME">newtext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdfEscape</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">newtext</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">flags</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>991</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>992</span> </span><span class="WHIT">			</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newtext.join</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">") Tj\nT* ("</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>993</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>994</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'Type of text must be string or Array. "'</span><span class="PUNC">+</span><span class="NAME">text</span><span class="PUNC">+</span><span class="STRN">'" is not recognized.'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT">		</span><span class="COMM">// Using "'" ("go next line and render text" mark) would save space but would complicate our rendering code, templates </span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">		
<span class='line'>998</span> 		</span><span class="COMM">// BT .. ET does NOT have default settings for Tf. You must state that explicitely every time for BT .. ET</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT">		</span><span class="COMM">// if you want text transformation matrix (+ multiline) to work reliably (which reads sizes of things from font declarations) </span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT">		</span><span class="COMM">// Thus, there is NO useful, *reliable* concept of "default" font for a page. </span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT">		</span><span class="COMM">// The fact that "default" (reuse font used before) font worked before in basic cases is an accident</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">		</span><span class="COMM">// - readers dealing smartly with brokenness of jsPDF's markup.</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="WHIT"> 
<span class='line'>1004</span> 			</span><span class="STRN">'BT\n/'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">			</span><span class="NAME">activeFontKey</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">activeFontSize</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' Tf\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="COMM">// font face, style, size</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT">			</span><span class="NAME">activeFontSize</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' TL\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="COMM">// line spacing</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="WHIT">			</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1008</span> 			</span><span class="STRN">'\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' Td\n('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1009</span> 			</span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1010</span> </span><span class="WHIT">			</span><span class="STRN">') Tj\nET'</span><span class="WHIT">
<span class='line'>1011</span> </span><span class="WHIT">		</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1013</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1014</span> 
<span class='line'>1015</span> </span><span class="WHIT">	</span><span class="NAME">API.line</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1016</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x1</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' m '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' l S'</span><span class="WHIT">			
<span class='line'>1019</span> 		</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1020</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1021</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1022</span> 
<span class='line'>1023</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1024</span> 	Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
<span class='line'>1025</span> 	All data points in `lines` are relative to last line origin.
<span class='line'>1026</span> 	`x`, `y` become x1,y1 for first line / curve in the set.
<span class='line'>1027</span> 	For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point.
<span class='line'>1028</span> 	For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1.
<span class='line'>1029</span> 	
<span class='line'>1030</span> 	@example .lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, 10) // line, line, bezier curve, line 
<span class='line'>1031</span> 	@param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
<span class='line'>1032</span> 	@param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1033</span> 	@param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1034</span> 	@param {Number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.   
<span class='line'>1035</span> 	@function
<span class='line'>1036</span> 	@returns {jsPDF}
<span class='line'>1037</span> 	@methodOf jsPDF#
<span class='line'>1038</span> 	@name lines
<span class='line'>1039</span> 	 */</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="WHIT">	</span><span class="NAME">API.lines</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">lines</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1041</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>1042</span> </span><span class="WHIT">		
<span class='line'>1043</span> 		</span><span class="COMM">// Pre-August-2012 the order of arguments was function(x, y, lines, scale, style)</span><span class="WHIT">
<span class='line'>1044</span> </span><span class="WHIT">		</span><span class="COMM">// in effort to make all calls have similar signature like </span><span class="WHIT">
<span class='line'>1045</span> </span><span class="WHIT">		</span><span class="COMM">//   function(content, coordinateX, coordinateY , miscellaneous)</span><span class="WHIT">
<span class='line'>1046</span> </span><span class="WHIT">		</span><span class="COMM">// this method had its args flipped.</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT">		</span><span class="COMM">// code below allows backward compatibility with old arg order.</span><span class="WHIT">
<span class='line'>1048</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_first</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_second</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">_third</span><span class="WHIT">
<span class='line'>1049</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">			</span><span class="NAME">_first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1051</span> </span><span class="WHIT">			</span><span class="NAME">_second</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">			</span><span class="NAME">_third</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1053</span> 
<span class='line'>1054</span> </span><span class="WHIT">			</span><span class="NAME">lines</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_first</span><span class="WHIT"> 
<span class='line'>1055</span> 			</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_second</span><span class="WHIT"> 
<span class='line'>1056</span> 			</span><span class="NAME">y</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_third</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1058</span> 
<span class='line'>1059</span> </span><span class="WHIT">		</span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getStyle</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1060</span> </span><span class="WHIT">		</span><span class="NAME">scale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="WHIT">
<span class='line'>1061</span> 
<span class='line'>1062</span> </span><span class="WHIT">		</span><span class="COMM">// starting point</span><span class="WHIT">
<span class='line'>1063</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' m '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1064</span> </span><span class="WHIT">		
<span class='line'>1065</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scalex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1066</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scaley</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scale</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1067</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>1068</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">lines.length</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="WHIT">
<span class='line'>1070</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="WHIT"> </span><span class="COMM">// bezier only. In page default measurement "units", *after* scaling</span><span class="WHIT">
<span class='line'>1071</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y3</span><span class="WHIT"> </span><span class="COMM">// bezier only. In page default measurement "units", *after* scaling</span><span class="WHIT">
<span class='line'>1072</span> </span><span class="WHIT">		</span><span class="COMM">// ending point for all, lines and bezier. . In page default measurement "units", *after* scaling</span><span class="WHIT">
<span class='line'>1073</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="COMM">// last / ending point = starting point for first item.</span><span class="WHIT">
<span class='line'>1074</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">y</span><span class="WHIT"> </span><span class="COMM">// last / ending point = starting point for first item.</span><span class="WHIT">
<span class='line'>1075</span> </span><span class="WHIT">		
<span class='line'>1076</span> 		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="WHIT">			</span><span class="NAME">leg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">lines</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1078</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">leg.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1079</span> </span><span class="WHIT">				</span><span class="COMM">// simple line</span><span class="WHIT">
<span class='line'>1080</span> </span><span class="WHIT">				</span><span class="NAME">x4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scalex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">x4</span><span class="WHIT"> </span><span class="COMM">// here last x4 was prior ending point</span><span class="WHIT">
<span class='line'>1081</span> </span><span class="WHIT">				</span><span class="NAME">y4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scaley</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="WHIT"> </span><span class="COMM">// here last y4 was prior ending point</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="WHIT">				</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">x4</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' l'</span><span class="PUNC">)</span><span class="WHIT">					
<span class='line'>1083</span> 			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1084</span> </span><span class="WHIT">				</span><span class="COMM">// bezier curve</span><span class="WHIT">
<span class='line'>1085</span> </span><span class="WHIT">				</span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scalex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">x4</span><span class="WHIT"> </span><span class="COMM">// here last x4 is prior ending point</span><span class="WHIT">
<span class='line'>1086</span> </span><span class="WHIT">				</span><span class="NAME">y2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scaley</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="WHIT"> </span><span class="COMM">// here last y4 is prior ending point					</span><span class="WHIT">
<span class='line'>1087</span> </span><span class="WHIT">				</span><span class="NAME">x3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scalex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">x4</span><span class="WHIT"> </span><span class="COMM">// here last x4 is prior ending point</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="WHIT">				</span><span class="NAME">y3</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scaley</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="WHIT"> </span><span class="COMM">// here last y4 is prior ending point										</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT">				</span><span class="NAME">x4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">4</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scalex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">x4</span><span class="WHIT"> </span><span class="COMM">// here last x4 was prior ending point</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT">				</span><span class="NAME">y4</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">leg</span><span class="PUNC">[</span><span class="NUMB">5</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">scaley</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="WHIT"> </span><span class="COMM">// here last y4 was prior ending point</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT">				</span><span class="NAME">out</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1092</span> </span><span class="WHIT">					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1093</span> 					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="WHIT">					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">x3</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1095</span> 					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>1096</span> </span><span class="WHIT">					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">x4</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1097</span> 					</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' c'</span><span class="WHIT">
<span class='line'>1098</span> </span><span class="WHIT">				</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1100</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">			
<span class='line'>1101</span> 		</span><span class="COMM">// stroking / filling / both the path</span><span class="WHIT">
<span class='line'>1102</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>1103</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1105</span> 
<span class='line'>1106</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1107</span> 	Adds a rectangle to PDF
<span class='line'>1108</span> 	
<span class='line'>1109</span> 	@param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1110</span> 	@param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1111</span> 	@param {Number} w Width (in units declared at inception of PDF document) 
<span class='line'>1112</span> 	@param {Number} h Height (in units declared at inception of PDF document) 
<span class='line'>1113</span> 	@param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
<span class='line'>1114</span> 	@function
<span class='line'>1115</span> 	@returns {jsPDF}
<span class='line'>1116</span> 	@methodOf jsPDF#
<span class='line'>1117</span> 	@name rect
<span class='line'>1118</span> 	 */</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT">	</span><span class="NAME">API.rect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getStyle</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1122</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1123</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1124</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1125</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1126</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'re'</span><span class="WHIT">
<span class='line'>1127</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT">
<span class='line'>1128</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1131</span> 
<span class='line'>1132</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1133</span> 	Adds a triangle to PDF
<span class='line'>1134</span> 	
<span class='line'>1135</span> 	@param {Number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1136</span> 	@param {Number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1137</span> 	@param {Number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1138</span> 	@param {Number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1139</span> 	@param {Number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1140</span> 	@param {Number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1141</span> 	@param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
<span class='line'>1142</span> 	@function
<span class='line'>1143</span> 	@returns {jsPDF}
<span class='line'>1144</span> 	@methodOf jsPDF#
<span class='line'>1145</span> 	@name triangle
<span class='line'>1146</span> 	 */</span><span class="WHIT">
<span class='line'>1147</span> </span><span class="WHIT">	</span><span class="NAME">API.triangle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1148</span> </span><span class="WHIT">		</span><span class="NAME">this.lines</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1149</span> </span><span class="WHIT">			</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1150</span> </span><span class="WHIT">				</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">x1</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// vector to point 2</span><span class="WHIT">
<span class='line'>1151</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">x3</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y3</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y2</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// vector to point 3</span><span class="WHIT">
<span class='line'>1152</span> </span><span class="WHIT">				</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">x1</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">x3</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y1</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">y3</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="COMM">// closing vector back to point 1</span><span class="WHIT">
<span class='line'>1153</span> </span><span class="WHIT">			</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1154</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x2</span><span class="WHIT"> </span><span class="COMM">// start of path</span><span class="WHIT">
<span class='line'>1155</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1156</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="WHIT">
<span class='line'>1157</span> </span><span class="WHIT">		</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1158</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1159</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1160</span> 
<span class='line'>1161</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1162</span> 	Adds an ellipse to PDF
<span class='line'>1163</span> 	
<span class='line'>1164</span> 	@param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1165</span> 	@param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1166</span> 	@param {Number} rx Radius along x axis (in units declared at inception of PDF document) 
<span class='line'>1167</span> 	@param {Number} rx Radius along y axis (in units declared at inception of PDF document) 
<span class='line'>1168</span> 	@param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
<span class='line'>1169</span> 	@function
<span class='line'>1170</span> 	@returns {jsPDF}
<span class='line'>1171</span> 	@methodOf jsPDF#
<span class='line'>1172</span> 	@name ellipse
<span class='line'>1173</span> 	 */</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="WHIT">	</span><span class="NAME">API.ellipse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ry</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1175</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getStyle</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1176</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">/</span><span class="NUMB">3</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">Math.SQRT2</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">rx</span><span class="WHIT">
<span class='line'>1177</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">/</span><span class="NUMB">3</span><span class="PUNC">*</span><span class="PUNC">(</span><span class="NAME">Math.SQRT2</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">ry</span><span class="WHIT">
<span class='line'>1178</span> </span><span class="WHIT">		
<span class='line'>1179</span> 		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1180</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1181</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'m'</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1184</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1185</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1186</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1187</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1188</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1189</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'c'</span><span class="WHIT">
<span class='line'>1190</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1195</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">-</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1196</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1197</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1198</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'c'</span><span class="WHIT">
<span class='line'>1199</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1200</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1201</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1202</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1203</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1204</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1205</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1206</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1207</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'c'</span><span class="WHIT">
<span class='line'>1208</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1209</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT">			</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">lx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ry</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1212</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1213</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">+</span><span class="NAME">ly</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1214</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">+</span><span class="NAME">rx</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1215</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">pageHeight</span><span class="PUNC">-</span><span class="NAME">y</span><span class="PUNC">)</span><span class="PUNC">*</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>1216</span> 			</span><span class="PUNC">,</span><span class="STRN">'c'</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT">		</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1219</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1221</span> 
<span class='line'>1222</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1223</span> 	Adds an circle to PDF
<span class='line'>1224</span> 	
<span class='line'>1225</span> 	@param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
<span class='line'>1226</span> 	@param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
<span class='line'>1227</span> 	@param {Number} r Radius (in units declared at inception of PDF document) 
<span class='line'>1228</span> 	@param {String} style (Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
<span class='line'>1229</span> 	@function
<span class='line'>1230</span> 	@returns {jsPDF}
<span class='line'>1231</span> 	@methodOf jsPDF#
<span class='line'>1232</span> 	@name circle
<span class='line'>1233</span> 	 */</span><span class="WHIT">
<span class='line'>1234</span> </span><span class="WHIT">	</span><span class="NAME">API.circle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.ellipse</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">r</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1237</span> 
<span class='line'>1238</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1239</span> 	Adds a properties to the PDF document
<span class='line'>1240</span> 	
<span class='line'>1241</span> 	@param {Object} A property_name-to-property_value object structure.
<span class='line'>1242</span> 	@function
<span class='line'>1243</span> 	@returns {jsPDF}
<span class='line'>1244</span> 	@methodOf jsPDF#
<span class='line'>1245</span> 	@name setProperties
<span class='line'>1246</span> 	 */</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="WHIT">	</span><span class="NAME">API.setProperties</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">properties</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="WHIT">		</span><span class="COMM">// copying only those properties we can render.</span><span class="WHIT">
<span class='line'>1249</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">property</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">documentProperties</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">documentProperties.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">property</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">				</span><span class="NAME">documentProperties</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1256</span> 
<span class='line'>1257</span> </span><span class="WHIT">	</span><span class="NAME">API.addImage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">imageData</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">w</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1258</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1260</span> 
<span class='line'>1261</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1262</span> 	Sets font size for upcoming text elements.
<span class='line'>1263</span> 	
<span class='line'>1264</span> 	@param {Number} size Font size in points.
<span class='line'>1265</span> 	@function
<span class='line'>1266</span> 	@returns {jsPDF}
<span class='line'>1267</span> 	@methodOf jsPDF#
<span class='line'>1268</span> 	@name setFontSize
<span class='line'>1269</span> 	 */</span><span class="WHIT">
<span class='line'>1270</span> </span><span class="WHIT">	</span><span class="NAME">API.setFontSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">size</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT">		</span><span class="NAME">activeFontSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">size</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1274</span> 
<span class='line'>1275</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1276</span> 	Sets text font face, variant for upcoming text elements.
<span class='line'>1277</span> 	See output of jsPDF.getFontList() for possible font names, styles.
<span class='line'>1278</span> 	
<span class='line'>1279</span> 	@param {String} fontName Font name or family. Example: "times"
<span class='line'>1280</span> 	@param {String} fontStyle Font style or variant. Example: "italic"
<span class='line'>1281</span> 	@function
<span class='line'>1282</span> 	@returns {jsPDF}
<span class='line'>1283</span> 	@methodOf jsPDF#
<span class='line'>1284</span> 	@name setFont
<span class='line'>1285</span> 	 */</span><span class="WHIT">
<span class='line'>1286</span> </span><span class="WHIT">	</span><span class="NAME">API.setFont</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1287</span> </span><span class="WHIT">		</span><span class="NAME">activeFontKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFont</span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1288</span> </span><span class="WHIT">		</span><span class="COMM">// if font is not found, the above line blows up and we never go further</span><span class="WHIT">
<span class='line'>1289</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1290</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1291</span> 
<span class='line'>1292</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1293</span> 	Switches font style or variant for upcoming text elements,
<span class='line'>1294</span> 	while keeping the font face or family same.
<span class='line'>1295</span> 	See output of jsPDF.getFontList() for possible font names, styles.
<span class='line'>1296</span> 	
<span class='line'>1297</span> 	@param {String} style Font style or variant. Example: "italic"
<span class='line'>1298</span> 	@function
<span class='line'>1299</span> 	@returns {jsPDF}
<span class='line'>1300</span> 	@methodOf jsPDF#
<span class='line'>1301</span> 	@name setFontStyle
<span class='line'>1302</span> 	 */</span><span class="WHIT">
<span class='line'>1303</span> </span><span class="WHIT">	</span><span class="NAME">API.setFontStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">API.setFontType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1304</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>1305</span> </span><span class="WHIT">		</span><span class="NAME">activeFontKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getFont</span><span class="PUNC">(</span><span class="NAME">undef</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1306</span> </span><span class="WHIT">		</span><span class="COMM">// if font is not found, the above line blows up and we never go further</span><span class="WHIT">
<span class='line'>1307</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1308</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1309</span> 
<span class='line'>1310</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1311</span> 	Returns an object - a tree of fontName to fontStyle relationships available to 
<span class='line'>1312</span> 	active PDF document. 
<span class='line'>1313</span> 
<span class='line'>1314</span> 	@public
<span class='line'>1315</span> 	@function
<span class='line'>1316</span> 	@returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }
<span class='line'>1317</span> 	@methodOf jsPDF#
<span class='line'>1318</span> 	@name getFontList
<span class='line'>1319</span> 	*/</span><span class="WHIT">
<span class='line'>1320</span> </span><span class="WHIT">	</span><span class="NAME">API.getFontList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1321</span> </span><span class="WHIT">		</span><span class="COMM">// TODO: iterate over fonts array or return copy of fontmap instead in case more are ever added.</span><span class="WHIT">
<span class='line'>1322</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1323</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontName</span><span class="WHIT">
<span class='line'>1324</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fontStyle</span><span class="WHIT">
<span class='line'>1325</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT">
<span class='line'>1326</span> 
<span class='line'>1327</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">fontmap</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1328</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontmap.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">fontName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1329</span> </span><span class="WHIT">				</span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1330</span> </span><span class="WHIT">				</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontStyle</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1331</span> </span><span class="WHIT">					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fontmap</span><span class="PUNC">[</span><span class="NAME">fontName</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1332</span> </span><span class="WHIT">						</span><span class="NAME">tmp.push</span><span class="PUNC">(</span><span class="NAME">fontStyle</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1333</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1334</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1335</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1336</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1337</span> 
<span class='line'>1338</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT">
<span class='line'>1339</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1340</span> 
<span class='line'>1341</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1342</span> 	Sets line width for upcoming lines.
<span class='line'>1343</span> 	
<span class='line'>1344</span> 	@param {Number} width Line width (in units declared at inception of PDF document)
<span class='line'>1345</span> 	@function
<span class='line'>1346</span> 	@returns {jsPDF}
<span class='line'>1347</span> 	@methodOf jsPDF#
<span class='line'>1348</span> 	@name setLineWidth
<span class='line'>1349</span> 	 */</span><span class="WHIT">
<span class='line'>1350</span> </span><span class="WHIT">	</span><span class="NAME">API.setLineWidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">width</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1351</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">width</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toFixed</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' w'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1352</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1353</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1354</span> 
<span class='line'>1355</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1356</span> 	Sets the stroke color for upcoming elements. 
<span class='line'>1357</span> 
<span class='line'>1358</span> 	Depending on the number of arguments given, Gray, RGB, or CMYK
<span class='line'>1359</span> 	color space is implied.
<span class='line'>1360</span> 
<span class='line'>1361</span> 	When only ch1 is given, "Gray" color space is implied and it
<span class='line'>1362</span> 	must be a value in the range from 0.00 (solid black) to to 1.00 (white)
<span class='line'>1363</span> 	if values are communicated as String types, or in range from 0 (black)
<span class='line'>1364</span> 	to 255 (white) if communicated as Number type.
<span class='line'>1365</span> 	The RGB-like 0-255 range is provided for backward compatibility.
<span class='line'>1366</span> 
<span class='line'>1367</span> 	When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
<span class='line'>1368</span> 	value must be in the range from 0.00 (minimum intensity) to to 1.00 
<span class='line'>1369</span> 	(max intensity) if values are communicated as String types, or 
<span class='line'>1370</span> 	from 0 (min intensity) to to 255 (max intensity) if values are communicated
<span class='line'>1371</span> 	as Number types.
<span class='line'>1372</span> 	The RGB-like 0-255 range is provided for backward compatibility.
<span class='line'>1373</span> 
<span class='line'>1374</span> 	When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
<span class='line'>1375</span> 	value must be a in the range from 0.00 (0% concentration) to to 
<span class='line'>1376</span> 	1.00 (100% concentration)
<span class='line'>1377</span> 
<span class='line'>1378</span> 	Because JavaScript treats fixed point numbers badly (rounds to 
<span class='line'>1379</span> 	floating point nearest to binary representation) it is highly advised to
<span class='line'>1380</span> 	communicate the fractional numbers as String types, not JavaScript Number type.
<span class='line'>1381</span> 	
<span class='line'>1382</span> 	@param {Number|String} ch1 Color channel value
<span class='line'>1383</span> 	@param {Number|String} ch2 Color channel value
<span class='line'>1384</span> 	@param {Number|String} ch3 Color channel value
<span class='line'>1385</span> 	@param {Number|String} ch4 Color channel value
<span class='line'>1386</span> 
<span class='line'>1387</span> 	@function
<span class='line'>1388</span> 	@returns {jsPDF}
<span class='line'>1389</span> 	@methodOf jsPDF#
<span class='line'>1390</span> 	@name setDrawColor
<span class='line'>1391</span> 	 */</span><span class="WHIT">
<span class='line'>1392</span> </span><span class="WHIT">	</span><span class="NAME">API.setDrawColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="NAME">ch4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1393</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT">
<span class='line'>1394</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">color</span><span class="WHIT">
<span class='line'>1395</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">ch4</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1396</span> </span><span class="WHIT">			</span><span class="COMM">// Gray color space.</span><span class="WHIT">
<span class='line'>1397</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1398</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' G'</span><span class="WHIT">
<span class='line'>1399</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1400</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' G'</span><span class="WHIT">
<span class='line'>1401</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1402</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ch4</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1403</span> </span><span class="WHIT">			</span><span class="COMM">// RGB</span><span class="WHIT">
<span class='line'>1404</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1405</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'RG'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1406</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1407</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch3</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'RG'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1408</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1409</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1410</span> </span><span class="WHIT">			</span><span class="COMM">// CMYK</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1412</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'K'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1413</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1414</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch3</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch4</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'K'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1415</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1416</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1417</span> 
<span class='line'>1418</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">color</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1419</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1420</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1421</span> 
<span class='line'>1422</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1423</span> 	Sets the fill color for upcoming elements. 
<span class='line'>1424</span> 	
<span class='line'>1425</span> 	Depending on the number of arguments given, Gray, RGB, or CMYK
<span class='line'>1426</span> 	color space is implied.
<span class='line'>1427</span> 
<span class='line'>1428</span> 	When only ch1 is given, "Gray" color space is implied and it
<span class='line'>1429</span> 	must be a value in the range from 0.00 (solid black) to to 1.00 (white)
<span class='line'>1430</span> 	if values are communicated as String types, or in range from 0 (black)
<span class='line'>1431</span> 	to 255 (white) if communicated as Number type.
<span class='line'>1432</span> 	The RGB-like 0-255 range is provided for backward compatibility.
<span class='line'>1433</span> 
<span class='line'>1434</span> 	When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
<span class='line'>1435</span> 	value must be in the range from 0.00 (minimum intensity) to to 1.00 
<span class='line'>1436</span> 	(max intensity) if values are communicated as String types, or 
<span class='line'>1437</span> 	from 0 (min intensity) to to 255 (max intensity) if values are communicated
<span class='line'>1438</span> 	as Number types.
<span class='line'>1439</span> 	The RGB-like 0-255 range is provided for backward compatibility.
<span class='line'>1440</span> 
<span class='line'>1441</span> 	When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
<span class='line'>1442</span> 	value must be a in the range from 0.00 (0% concentration) to to 
<span class='line'>1443</span> 	1.00 (100% concentration)
<span class='line'>1444</span> 
<span class='line'>1445</span> 	Because JavaScript treats fixed point numbers badly (rounds to 
<span class='line'>1446</span> 	floating point nearest to binary representation) it is highly advised to
<span class='line'>1447</span> 	communicate the fractional numbers as String types, not JavaScript Number type.
<span class='line'>1448</span> 	
<span class='line'>1449</span> 	@param {Number|String} ch1 Color channel value
<span class='line'>1450</span> 	@param {Number|String} ch2 Color channel value
<span class='line'>1451</span> 	@param {Number|String} ch3 Color channel value
<span class='line'>1452</span> 	@param {Number|String} ch4 Color channel value
<span class='line'>1453</span> 
<span class='line'>1454</span> 	@function
<span class='line'>1455</span> 	@returns {jsPDF}
<span class='line'>1456</span> 	@methodOf jsPDF#
<span class='line'>1457</span> 	@name setFillColor
<span class='line'>1458</span> 	 */</span><span class="WHIT">
<span class='line'>1459</span> </span><span class="WHIT">	</span><span class="NAME">API.setFillColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">color</span><span class="WHIT">
<span class='line'>1462</span> 
<span class='line'>1463</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">ch4</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1464</span> </span><span class="WHIT">			</span><span class="COMM">// Gray color space.</span><span class="WHIT">
<span class='line'>1465</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1466</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' g'</span><span class="WHIT">
<span class='line'>1467</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1468</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' g'</span><span class="WHIT">
<span class='line'>1469</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1470</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ch4</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1471</span> </span><span class="WHIT">			</span><span class="COMM">// RGB</span><span class="WHIT">
<span class='line'>1472</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1473</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rg'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1475</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch3</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rg'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1476</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1477</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1478</span> </span><span class="WHIT">			</span><span class="COMM">// CMYK</span><span class="WHIT">
<span class='line'>1479</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ch1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1480</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">ch1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ch4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'k'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1481</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1482</span> </span><span class="WHIT">				</span><span class="NAME">color</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch1</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch3</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f2</span><span class="PUNC">(</span><span class="NAME">ch4</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'k'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1483</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1484</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1485</span> 
<span class='line'>1486</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">color</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1487</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1488</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1489</span> 
<span class='line'>1490</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1491</span> 	Sets the text color for upcoming elements. 
<span class='line'>1492</span> 	If only one, first argument is given,
<span class='line'>1493</span> 	treats the value as gray-scale color value.
<span class='line'>1494</span> 	
<span class='line'>1495</span> 	@param {Number} r Red channel color value in range 0-255
<span class='line'>1496</span> 	@param {Number} g Green channel color value in range 0-255
<span class='line'>1497</span> 	@param {Number} b Blue channel color value in range 0-255
<span class='line'>1498</span> 	@function
<span class='line'>1499</span> 	@returns {jsPDF}
<span class='line'>1500</span> 	@methodOf jsPDF#
<span class='line'>1501</span> 	@name setTextColor
<span class='line'>1502</span> 	*/</span><span class="WHIT">
<span class='line'>1503</span> </span><span class="WHIT">	</span><span class="NAME">API.setTextColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">,</span><span class="NAME">g</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1504</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">g</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">b</span><span class="PUNC">===</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">g</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1505</span> </span><span class="WHIT">			</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' g'</span><span class="WHIT">
<span class='line'>1506</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1507</span> </span><span class="WHIT">			</span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">r</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">g</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f3</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">/</span><span class="NUMB">255</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rg'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1508</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1509</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1510</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1511</span> 
<span class='line'>1512</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1513</span> 	Is an Object providing a mapping from human-readable to
<span class='line'>1514</span> 	integer flag values designating the varieties of line cap 
<span class='line'>1515</span> 	and join styles.
<span class='line'>1516</span> 	
<span class='line'>1517</span> 	@returns {Object}
<span class='line'>1518</span> 	@fieldOf jsPDF#
<span class='line'>1519</span> 	@name CapJoinStyles
<span class='line'>1520</span> 	*/</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT">	</span><span class="NAME">API.CapJoinStyles</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="WHIT">		</span><span class="NUMB">0</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'butt'</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'but'</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'bevel'</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="WHIT">
<span class='line'>1523</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'round'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rounded'</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'circle'</span><span class="PUNC">:</span><span class="NUMB">1</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'projecting'</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'project'</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'square'</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'milter'</span><span class="PUNC">:</span><span class="NUMB">2</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1526</span> 
<span class='line'>1527</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1528</span> 	Sets the line cap styles
<span class='line'>1529</span> 	See {jsPDF.CapJoinStyles} for variants
<span class='line'>1530</span> 	
<span class='line'>1531</span> 	@param {String|Number} style A string or number identifying the type of line cap
<span class='line'>1532</span> 	@function
<span class='line'>1533</span> 	@returns {jsPDF}
<span class='line'>1534</span> 	@methodOf jsPDF#
<span class='line'>1535</span> 	@name setLineCap
<span class='line'>1536</span> 	*/</span><span class="WHIT">
<span class='line'>1537</span> </span><span class="WHIT">	</span><span class="NAME">API.setLineCap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1538</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT">
<span class='line'>1539</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.CapJoinStyles</span><span class="PUNC">[</span><span class="NAME">style</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1540</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1541</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Line cap style of '"</span><span class="PUNC">+</span><span class="NAME">style</span><span class="PUNC">+</span><span class="STRN">"' is not recognized. See or extend .CapJoinStyles property for valid styles"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1542</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1543</span> </span><span class="WHIT">		</span><span class="NAME">lineCapID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT">
<span class='line'>1544</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">id.toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' J'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1545</span> 
<span class='line'>1546</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1547</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1548</span> 
<span class='line'>1549</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1550</span> 	Sets the line join styles
<span class='line'>1551</span> 	See {jsPDF.CapJoinStyles} for variants
<span class='line'>1552</span> 	
<span class='line'>1553</span> 	@param {String|Number} style A string or number identifying the type of line join
<span class='line'>1554</span> 	@function
<span class='line'>1555</span> 	@returns {jsPDF}
<span class='line'>1556</span> 	@methodOf jsPDF#
<span class='line'>1557</span> 	@name setLineJoin
<span class='line'>1558</span> 	*/</span><span class="WHIT">
<span class='line'>1559</span> </span><span class="WHIT">	</span><span class="NAME">API.setLineJoin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1560</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT">
<span class='line'>1561</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.CapJoinStyles</span><span class="PUNC">[</span><span class="NAME">style</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1562</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1563</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"Line join style of '"</span><span class="PUNC">+</span><span class="NAME">style</span><span class="PUNC">+</span><span class="STRN">"' is not recognized. See or extend .CapJoinStyles property for valid styles"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1564</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1565</span> </span><span class="WHIT">		</span><span class="NAME">lineJoinID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT">
<span class='line'>1566</span> </span><span class="WHIT">		</span><span class="NAME">out</span><span class="PUNC">(</span><span class="NAME">id.toString</span><span class="PUNC">(</span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' j'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1567</span> 
<span class='line'>1568</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="WHIT">
<span class='line'>1569</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1570</span> 
<span class='line'>1571</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>1572</span> 	Generates the PDF document.
<span class='line'>1573</span> 	Possible values:
<span class='line'>1574</span> 		datauristring (alias dataurlstring) - Data-Url-formatted data returned as string.
<span class='line'>1575</span> 		datauri (alias datauri) - Data-Url-formatted data pushed into current window's location (effectively reloading the window with contents of the PDF).
<span class='line'>1576</span> 	
<span class='line'>1577</span> 	If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
<span class='line'>1578</span> 
<span class='line'>1579</span> 	@param {String} type A string identifying one of the possible output types.
<span class='line'>1580</span> 	@param {Object} options An object providing some additional signalling to PDF generator.
<span class='line'>1581</span> 	@function
<span class='line'>1582</span> 	@returns {jsPDF}
<span class='line'>1583</span> 	@methodOf jsPDF#
<span class='line'>1584</span> 	@name output
<span class='line'>1585</span> 	*/</span><span class="WHIT">
<span class='line'>1586</span> </span><span class="WHIT">	</span><span class="NAME">API.output</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1587</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="WHIT">
<span class='line'>1588</span> </span><span class="WHIT">		</span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1589</span> </span><span class="WHIT">			</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">undef</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">buildDocument</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>1590</span> 			</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'datauristring'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1591</span> </span><span class="WHIT">			</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'dataurlstring'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1592</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'data:application/pdf;base64,'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">btoa</span><span class="PUNC">(</span><span class="NAME">buildDocument</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1593</span> </span><span class="WHIT">			</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'datauri'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1594</span> </span><span class="WHIT">			</span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'dataurl'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1595</span> </span><span class="WHIT">				</span><span class="NAME">document.location.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'data:application/pdf;base64,'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">btoa</span><span class="PUNC">(</span><span class="NAME">buildDocument</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1596</span> </span><span class="WHIT">			</span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'Output type "'</span><span class="PUNC">+</span><span class="NAME">type</span><span class="PUNC">+</span><span class="STRN">'" is not supported.'</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>1597</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1598</span> </span><span class="WHIT">		</span><span class="COMM">// @TODO: Add different output options</span><span class="WHIT">
<span class='line'>1599</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1600</span> 
<span class='line'>1601</span> </span><span class="WHIT">	</span><span class="COMM">// applying plugins (more methods) ON TOP of built-in API.</span><span class="WHIT">
<span class='line'>1602</span> </span><span class="WHIT">	</span><span class="COMM">// this is intentional as we allow plugins to override </span><span class="WHIT">
<span class='line'>1603</span> </span><span class="WHIT">	</span><span class="COMM">// built-ins</span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">jsPDF.API</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1605</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">jsPDF.API.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1606</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'events'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">jsPDF.API.events.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1607</span> </span><span class="WHIT">				</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">events</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newEvents</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1608</span> 
<span class='line'>1609</span> </span><span class="WHIT">					</span><span class="COMM">// jsPDF.API.events is a JS Array of Arrays </span><span class="WHIT">
<span class='line'>1610</span> </span><span class="WHIT">					</span><span class="COMM">// where each Array is a pair of event name, handler</span><span class="WHIT">
<span class='line'>1611</span> </span><span class="WHIT">					</span><span class="COMM">// Events were added by plugins to the jsPDF instantiator.</span><span class="WHIT">
<span class='line'>1612</span> </span><span class="WHIT">					</span><span class="COMM">// These are always added to the new instance and some ran</span><span class="WHIT">
<span class='line'>1613</span> </span><span class="WHIT">					</span><span class="COMM">// during instantiation.</span><span class="WHIT">
<span class='line'>1614</span> 
<span class='line'>1615</span> </span><span class="WHIT">					</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">eventname</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handler_and_args</span><span class="WHIT">
<span class='line'>1616</span> 
<span class='line'>1617</span> </span><span class="WHIT">					</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newEvents.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1618</span> </span><span class="WHIT">						</span><span class="COMM">// subscribe takes 3 args: 'topic', function, runonce_flag</span><span class="WHIT">
<span class='line'>1619</span> </span><span class="WHIT">						</span><span class="COMM">// if undefined, runonce is false.</span><span class="WHIT">
<span class='line'>1620</span> </span><span class="WHIT">						</span><span class="COMM">// users can attach callback directly, </span><span class="WHIT">
<span class='line'>1621</span> </span><span class="WHIT">						</span><span class="COMM">// or they can attach an array with [callback, runonce_flag]</span><span class="WHIT">
<span class='line'>1622</span> </span><span class="WHIT">						</span><span class="COMM">// that's what the "apply" magic is for below.</span><span class="WHIT">
<span class='line'>1623</span> </span><span class="WHIT">						</span><span class="NAME">eventname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newEvents</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1624</span> </span><span class="WHIT">						</span><span class="NAME">handler_and_args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newEvents</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1625</span> </span><span class="WHIT">						</span><span class="NAME">events.subscribe.apply</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1626</span> </span><span class="WHIT">							</span><span class="NAME">events</span><span class="WHIT">
<span class='line'>1627</span> </span><span class="WHIT">							</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">eventname</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">concat</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1628</span> </span><span class="WHIT">								</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handler_and_args</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>1629</span> </span><span class="WHIT">							  	</span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">handler_and_args</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>1630</span> </span><span class="WHIT">							  	</span><span class="NAME">handler_and_args</span><span class="WHIT">
<span class='line'>1631</span> </span><span class="WHIT">							</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1632</span> </span><span class="WHIT">						</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1633</span> </span><span class="WHIT">					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1634</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">events</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">jsPDF.API.events</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1635</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1636</span> </span><span class="WHIT">				</span><span class="NAME">API</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jsPDF.API</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>1637</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1638</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1639</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1640</span> 
<span class='line'>1641</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////////////////////////</span><span class="WHIT">
<span class='line'>1642</span> </span><span class="WHIT">	</span><span class="COMM">// continuing initilisation of jsPDF Document object</span><span class="WHIT">
<span class='line'>1643</span> </span><span class="WHIT">	</span><span class="COMM">/////////////////////////////////////////</span><span class="WHIT">
<span class='line'>1644</span> 
<span class='line'>1645</span> 
<span class='line'>1646</span> </span><span class="WHIT">	</span><span class="COMM">// Add the first page automatically</span><span class="WHIT">
<span class='line'>1647</span> </span><span class="WHIT">	</span><span class="NAME">addFonts</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1648</span> </span><span class="WHIT">	</span><span class="NAME">activeFontKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'F1'</span><span class="WHIT">
<span class='line'>1649</span> </span><span class="WHIT">	</span><span class="NAME">_addPage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1650</span> 
<span class='line'>1651</span> </span><span class="WHIT">	</span><span class="NAME">events.publish</span><span class="PUNC">(</span><span class="STRN">'initialized'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1652</span> 
<span class='line'>1653</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">API</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1655</span> 
<span class='line'>1656</span> </span><span class="COMM">/**
<span class='line'>1657</span> jsPDF.API is a STATIC property of jsPDF class.
<span class='line'>1658</span> jsPDF.API is an object you can add methods and properties to.
<span class='line'>1659</span> The methods / properties you add will show up in new jsPDF objects.
<span class='line'>1660</span> 
<span class='line'>1661</span> One property is prepopulated. It is the 'events' Object. Plugin authors can add topics, callbacks to this object. These will be reassigned to all new instances of jsPDF. 
<span class='line'>1662</span> Examples: 
<span class='line'>1663</span> 	jsPDF.API.events['initialized'] = function(){ 'this' is API object }
<span class='line'>1664</span> 	jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }
<span class='line'>1665</span> 
<span class='line'>1666</span> @static
<span class='line'>1667</span> @public
<span class='line'>1668</span> @memberOf jsPDF
<span class='line'>1669</span> @name API
<span class='line'>1670</span> 
<span class='line'>1671</span> @example
<span class='line'>1672</span> 	jsPDF.API.mymethod = function(){
<span class='line'>1673</span> 		// 'this' will be ref to internal API object. see jsPDF source
<span class='line'>1674</span> 		// , so you can refer to built-in methods like so: 
<span class='line'>1675</span> 		//	 this.line(....)
<span class='line'>1676</span> 		//	 this.text(....)
<span class='line'>1677</span> 	}
<span class='line'>1678</span> 	var pdfdoc = new jsPDF()
<span class='line'>1679</span> 	pdfdoc.mymethod() // &lt;- !!!!!!	
<span class='line'>1680</span> */</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="NAME">jsPDF.API</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'events'</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1682</span> 
<span class='line'>1683</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">jsPDF</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1685</span> </span></pre></body></html>